Page({
  /**
   * 页面的初始数据
   */
  data: {
    params: {
      page: 2,
    },
    jobList: []
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    const that = this;
    if (typeof this.getTabBar === 'function' &&
      that.getTabBar()) {
      that.getTabBar().setData({
        selected: 1
      })
    }
    getApp().globalData.get("/api/part_time/list",{}).then(res=>{
      that.data.params.page = 2;
      that.setData({
        jobList: res.data,
        params: that.data.params
      })
    })
  },
  onReachBottom() {
    const that = this;
    getApp().globalData.get("/api/part_time/list", {
      page: that.data.params.page,
      size: 10
    }).then(res => {
      that.data.params.page = that.data.params.page + 1;
      that.setData({
        jobList: that.data.jobList.concat(res.data),
        params: that.data.params
      })
    })
  },
  onPullDownRefresh() {
    const that = this;
    that.data.params.page = 1;
    getApp().globalData.get("/api/part_time/list", {}).then(res => {
      that.data.params.page = 2;
      that.setData({
        jobList: res.data,
        params: that.data.params
      })
      wx.stopPullDownRefresh()
    })
  },
  dataListener(e) {//选择筛选条件后的获取数据
    const that = this;
    that.data.params.page = 1;
    that.data.params.condition = e.detail;
    let condition = that.data.params.condition;
    condition.size = 10;
    getApp().globalData.get("/api/part_time/list", {
      condition
    }).then(res => {
      that.data.params.page = 1;
      that.setData({
        jobList: res.data,
        params: that.data.params
      })
    })
  }
})